function feat = getHist( img , color_code , bin_num )

if nargin< 2
    color_code = 'hsv';
end

if strcmpi(color_code, 'hsv')
    img = rgb2hsv( img );
end

if nargin< 3
    bin_num  = int32([4 4 4 ]);
end


for k = 1:3
    ch{k} = img(:,:,k);
    ch{k} = ch{k}(:);
    step = 1/double(bin_num(k));
    if max(ch{k})>1
        disp('warning! unnormed channel');
    end
    ch{k} = floor( ch{k} / step ) ;
    ch{k}( ch{k} >= bin_num(k) ) = bin_num(k)-1;
    ch{k} = int32( ch{k} );
end

id = ch{1} + ch{2} * bin_num(1) + ch{3} * bin_num(1) * bin_num(2);

X = tabulate(id);

feat = zeros(1, prod( double(bin_num) ) );

for i = 1:size(X,1)
    feat( X(i,1)+1 ) = X(i,3)/100;
end
